package com.zbkj.admin.controller.mszs;


import com.zbkj.common.model.mszs.MszsRoomRecord;
import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.common.request.mszs.MszsRoomRecordRequest;
import com.zbkj.common.request.mszs.MszsRoomRecordSelectRequest;
import com.zbkj.common.response.CommonResult;
import com.zbkj.common.response.mszs.MszsRoomRecordResponse;
import com.zbkj.service.service.mszs.MszsRoomRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController("MszsRoomRecordController")
@RequestMapping("api/admin/mszs/room/record")
@Api(tags = "民宿助手-管理平台-酒店房间入住记录信息")
public class MszsRoomRecordController {

    @Resource
    private MszsRoomRecordService recordService;

    @ApiOperation(value="新增-酒店房间入住记录")
    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    public CommonResult<Boolean> insert(@RequestBody @Validated MszsRoomRecordRequest request){
        return CommonResult.success(recordService.insert(request));
    }

    @ApiOperation(value="修改-酒店房间入住记录")
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public CommonResult<Boolean> update(@RequestBody @Validated MszsRoomRecordRequest request){
        return CommonResult.success(recordService.update(request));
    }

    @ApiOperation(value="刪除-根据id标识删除")
    @RequestMapping(value = "/delete", method = RequestMethod.GET)
    @ApiImplicitParam(name = "id", value = "主键id标识",required = true)
    public CommonResult<Boolean> del(@RequestParam("id")Integer id){
        return CommonResult.success(recordService.delete(id));
    }

    @ApiOperation(value="查询-根据主键id查询")
    @RequestMapping(value = "/load", method = RequestMethod.GET)
    @ApiImplicitParam(name = "id", value = "主键id标识",required = true)
    public CommonResult<MszsRoomRecordResponse> load(@RequestParam("id") Integer id) {
        return CommonResult.success(recordService.load(id));
    }

    @ApiOperation(value="查询-分页查询")
    @RequestMapping(value = "/pageList", method = RequestMethod.GET)
    public CommonResult<CommonPage<MszsRoomRecord>> pageList(
            @Validated MszsRoomRecordSelectRequest request,
            @Validated PageParamRequest pageParamRequest) {
        CommonPage<MszsRoomRecord> restPage = CommonPage.restPage(recordService.pageList(request,pageParamRequest));
        return CommonResult.success(restPage);
    }


}
